<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
  <title> {$Think.config.app_name} 后台管理 </title>
  <!-- 样 式 文 件 -->
  <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
  <link rel="stylesheet" href="/static/admin/css/other/login.css" />
</head>
<!-- 代 码 结 构 -->
<body style="background-size: cover;">
<form class="layui-form" action="javascript:void(0);">
  <div class="layui-form-item">
    <img class="logo" src="/static/admin/images/logo.png" />
    <div class="title">{$Think.config.app_name}Yun</div>
    <div class="desc">
      {$Think.config.app_name} 后台管理
    </div>
  </div>
  <div class="layui-form-item">
    <input placeholder="账 户" type="text" name="username" hover class="layui-input"/>
  </div>
  <div class="layui-form-item">
    <input placeholder="密 码" type="password" name="password"  hover class="layui-input"/>
  </div>
  <div class="layui-form-item">
    <input placeholder="验证码 : " type="text" maxlength="4" name="captcha" hover class="code layui-input layui-input-inline"/>
    <img id="codeimg" class="codeImage" style="cursor: pointer;width: calc(100% - 192px);"/>
  </div>

  <br>
  <div class="layui-form-item">
    <button  class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
      登 入
    </button>
  </div>
</form>
<!-- 资 源 引 入 -->
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
  layui.use(['form', 'layer', 'jquery', 'element'], function () {
    var $ = layui.jquery
            , layer = layui.layer
            , element = layui.element
            , form = layui.form;
    // 登 录 提 交
    form.on('submit(login)', function(data) {
      layer.load();
      $.ajax({
        type: "POST",
        data: data.field,
        success: function (res) {
          layer.closeAll('loading');
          if (res.code == 200){
            layer.msg(res.msg,{icon:1,time:1000},function () {
              location.href = "{:url('index/index')}";
            })
          } else {
            layer.msg(res.msg,{icon:2,time:1000},function () {
              initCode();
            })
          }
        }
      });
      return false;
    });
    initCode();
    function initCode() {
      $('#codeimg').attr("src","{:url('auth/verify')}?data=" + new Date().getTime());
    }

    $('#codeimg').on('click', function () {
      initCode();
    });
  })
</script>
</body>
</html>
